﻿package net.wangit.jdbc.generator;

import net.wangit.jdbc.table.TableConfigurationException;
import net.wangit.util.Checker;

public class IncrementGenerator implements Generator {

	private String domain;
	private String id;

	public IncrementGenerator(String domain, String id) {
		if (Checker.isEmpty(id)) {
			throw new TableConfigurationException(
					"IncrementGenerator could not be created without incrementorId!");
		} else {
			this.domain = domain;
			this.id = id;
			return;
		}
	}

	public String generate() {
		Incrementor incrementor = IncrementorFactory.getIncrementor(domain, id);
		return incrementor.next();
	}
}
